fin = open("input.txt", "r")
fin2 = open("ans.txt", "r")
finLines = fin.readlines()
fin2Lines = fin2.readlines()

finLineIdx = 0
fin2LineIdx = 0
t = 0
finLineIdx=finLineIdx+1 while finLines[finLineIdx].strip.length==0
t = finLines[finLineIdx].to_i

1.upto(t) {|testcase|
	begin
		finLineIdx=finLineIdx+1
		finLineIdx=finLineIdx+1 while finLines[finLineIdx].strip.length==0
		line = finLines[finLineIdx]
		n,m = line.split(' ').map!{|x| x.to_i}
		adjMat = Array.new(n+1){Array.new(n+1,0)}
		1.upto(m) {
			finLineIdx=finLineIdx+1
			finLineIdx=finLineIdx+1 while finLines[finLineIdx].strip.length==0
			line = finLines[finLineIdx]
			a,b=line.split(' ').map!{|x| x.to_i-1}
			adjMat[a][b] = adjMat[b][a] = 1
		}
		
		
		blacks = fin2Lines[testcase*2-1].split(' ').map!{|x| x.to_i-1}
		blacks.each { |x|
			blacks.each { |y|
				if adjMat[x][y]==1
					puts "wrong! #{x} #{y}"
					raise
				end
			}
		}
	rescue
		puts "error!"
	else
		puts "correct!"
	end
}
